package com.github.excel.controller;

import com.github.excel.entity.vo.request.RequestData;
import com.github.excel.entity.vo.response.ResponseData;
import com.github.excel.service.IDownloadFileService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 文件下载
 * @author sjw
 * @since 2024-01-18
 */
@RestController
@RequestMapping("/downloadFile")
public class DownloadFileController {

    @Autowired
    private IDownloadFileService downloadFileService;

    @GetMapping("/getFileDownLoadTaskId")
    @ApiOperation("获文件下载的任务id")
    public ResponseData<String> getFileDownLoadTaskId(@RequestBody RequestData<List<String>> model) {
        return ResponseData.ok(downloadFileService.getFileDownLoadTaskId(model.getData()));
    }

    @GetMapping(value = "/getFileZipByTaskId")
    @ApiOperation("根据下载任务id获取下载文件zip压缩包")
    public void getFileZipByTaskId(@RequestParam(value = "taskId")String taskId){
        downloadFileService.getFileZipByTaskId(taskId);
    }
}
